'##############
'Siemens VDO Script
'##############

'Симуляция работы бортового компьютера на MB O520

'(c) 22.10.2013 Сергей Wizard | omnibussimulator.ru

'(c) Revision 23.10.2013 | Сергей Wizard

'(c) 2013 Все права защищены и охраняются Российским Законодательством


' Описание триггеров кнопок смены экранов. Количество экранов: 4 + 1

{macro:VDO_init}
1 (S.L.display_option)
100 random (S.L.EBS_Error_dist)
{end}

{trigger:comp_button_up}

(L.L.number_of_display) 1 + (S.L.number_of_display)

	(L.L.number_of_display) 4 >
		{if}
	1 (S.L.number_of_display)
		{endif}

1 (S.L.comp_button_up_mode) s0
(M.L.kippschaltersound_toggle)
{end}

{trigger:comp_button_up_off}
 
0 (S.L.comp_button_up_mode) s0
(M.L.kippschaltersound_toggle)
{end}


{trigger:comp_button_down}

(L.L.number_of_display) 1 - (S.L.number_of_display)

	(L.L.number_of_display) 1 <
		{if}
	4 (S.L.number_of_display)
		{endif}


1 (S.L.comp_button_down_mode) s0
(M.L.kippschaltersound_toggle)
{end}

{trigger:comp_button_down_off}
 
0 (S.L.comp_button_down_mode) s0
(M.L.kippschaltersound_toggle)
{end}



{trigger:comp_button_qiut}

	1 (S.L.number_of_display)
	1 (S.L.warning_quit)


1 (S.L.comp_button_qiut_mode) s0
(M.L.kippschaltersound_toggle)
{end}

{trigger:comp_button_qiut_off}

0 (S.L.comp_button_qiut_mode) s0
(M.L.kippschaltersound_toggle)
{end}


{trigger:comp_button_system}

5 (S.L.number_of_display)
0 (S.L.warning_quit)
		

1 (S.L.comp_button_system_mode) s0
(M.L.kippschaltersound_toggle)
{end}

{trigger:comp_button_system_off}

0 (S.L.comp_button_system_mode) s0
(M.L.kippschaltersound_toggle)
{end}


{trigger:comp_button_info}

(L.L.display_option) 1 + (S.L.display_option)

	(L.L.display_option) 2 >
	{if}
	1 (S.L.display_option)
	{endif}


1 (S.L.comp_button_info_mode) s0
(M.L.kippschaltersound_toggle)
{end}

{trigger:comp_button_info_off}
 
0 (S.L.comp_button_info_mode) s0
(M.L.kippschaltersound_toggle)
{end}


{macro:Siemens_VDO_frame}

	(L.L.elec_busbar_main) 0 >
	{if}
		(L.L.startup_display) (L.S.Timegap) + 10 min (S.L.startup_display)
	{else}
		0 (S.L.startup_display)
		1 (S.L.number_of_display)
		1 (S.L.display_option)
	{endif}

	(L.L.startup_display) 5.5 > (L.L.startup_display) 6 < &&
	{if}
		2 (S.L.number_of_display)
	{endif}
	(L.L.startup_display) 6 > (L.L.startup_display) 6.5 < &&
	{if}
		3 (S.L.number_of_display)
	{endif}
	(L.L.startup_display) 6.5 > (L.L.startup_display) 7 < &&
	{if}
		4 (S.L.number_of_display)
	{endif}
	(L.L.startup_display) 7 > (L.L.startup_display) 7.5 < &&
	{if}
		1 (S.L.number_of_display)
	{endif}

'Условия появления рисунков дисплеев в зависимости от выбранного дисплея (о как!): 

	(L.L.number_of_display) 1 =
		{if}
		(L.L.door_0) 0 =
		(L.L.door_1) 0 = &&
		(L.L.door_2) 0 = &&
		(L.L.door_3) 0 = &&
		(L.L.door_4) 0 = &&
		(L.L.door_5) 0 = &&
		(L.L.light_timer1) 1 >= &&
		(L.L.light_timer2) 1 >= &&
		(L.L.light_timer3) 1 >= &&
		(L.L.bremse_halte) 0 = &&
		(L.L.cockpit_light_feststellbremse) 0 = &&
		(L.L.automatic_N_light) 0 = &&
		(L.L.startup_display) 8 > &&
		(L.L.startup_display) 0 > (L.L.startup_display) 8 < && ||
			{if}
			1 (S.L.display_idle_visible)
			0 (S.L.display_1_visible) (S.L.display_2_visible) (S.L.display_3_visible) (S.L.display_4_visible) (S.L.display_5_visible)
			{else}
			1 (S.L.display_1_visible)
			0 (S.L.display_idle_visible) (S.L.display_2_visible) (S.L.display_3_visible) (S.L.display_4_visible) (S.L.display_5_visible)
			{endif}
		{else}
	(L.L.number_of_display) 2 =
		{if}
			1 (S.L.display_2_visible)
			0 (S.L.display_idle_visible) (S.L.display_1_visible) (S.L.display_3_visible) (S.L.display_4_visible) (S.L.display_5_visible)
		{else}
	(L.L.number_of_display) 3 =
		{if}
			1 (S.L.display_3_visible)
			0 (S.L.display_idle_visible) (S.L.display_1_visible) (S.L.display_2_visible) (S.L.display_4_visible) (S.L.display_5_visible)
		{else}
	(L.L.number_of_display) 4 =
		{if}
			1 (S.L.display_4_visible)
			0 (S.L.display_idle_visible) (S.L.display_1_visible) (S.L.display_2_visible) (S.L.display_3_visible) (S.L.display_5_visible)
		{else}
	(L.L.number_of_display) 5 =
		{if}
			1 (S.L.display_5_visible)
			0 (S.L.display_idle_visible) (S.L.display_1_visible) (S.L.display_2_visible) (S.L.display_3_visible) (S.L.display_4_visible)
		{endif}
		{endif}
		{endif}
		{endif}
		{endif}


'Allgemeine Anzeigen:

	(L.L.display_idle_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.cp_klappfenster_OL3) &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 3 > (L.L.startup_display) 3.5 < && ||
		{if}
			1 (S.L.display1_Dachluke2)
		{else}
			0 (S.L.display1_Dachluke2)
		{endif}

	(L.L.elec_busbar_main) 0 >
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 0 > (L.L.startup_display) 9 < && ||
			{if}
		1 (S.L.display1_olddisplay)
			{else}
		0 (S.L.display1_olddisplay)
			{endif}

	(L.L.elec_busbar_main) 0 >
	(L.L.startup_display) 0 >= (L.L.startup_display) 9 < && (L.L.display1_Dachluke) 0 = && (L.L.display1_Dachluke2) 0 = && &&
			{if}
		1 (S.L.display1_olddisplay2)
			{else}
		0 (S.L.display1_olddisplay2)
			{endif}

	(L.L.display_1_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.door_4) 0 = &&
	(L.L.door_5) 0 = &&
	(L.L.bus_dooraft_sw) 1 = &&
	(L.L.startup_display) 8 > &&
	{if}
		(L.L.tuerfreigabe_timer) (L.S.Timegap) + 2 min (S.L.tuerfreigabe_timer)
		1 >
		{if}
			1 (S.L.display1_tuerfreigabe)
		{else}
			0 (S.L.display1_tuerfreigabe)
		{endif}
		(L.L.tuerfreigabe_timer) 2 =
		{if}
			0 (S.L.tuerfreigabe_timer)
		{endif}
	{else}
		0 (S.L.display1_tuerfreigabe)
		0 (S.L.tuerfreigabe_timer)
	{endif}

	(L.L.elec_busbar_main) 0 >
	(L.L.pandus_opn) 1 = &&
	(L.L.display_1_visible) 1 = &&
	(L.L.startup_display) 8 > &&
			{if}
		1 (S.L.display1_ramp)
			{else}
		0 (S.L.display1_ramp)
			{endif}

	(L.L.elec_busbar_main) 0 >
	(L.L.antrieb_wendesatz) 1 = &&
'	(L.L.brake) 0.15 < &&
	(L.L.display_idle_visible) 1 = &&
	(L.L.antrieb_getr_gangwahl) 0 > &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 0.5 > (L.L.startup_display) 1 < && ||
			{if}
		1 (S.L.display1_retarder)
			{else}
		0 (S.L.display1_retarder)
			{endif}

'	(L.L.elec_busbar_main) 0 >
'	(L.L.antrieb_wendesatz) 1 = &&
'	(L.L.brake) 0.15 >= && (L.L.brake) 0.25 < &&
'	(L.L.display_idle_visible) 1 = &&
'	(L.L.antrieb_getr_gangwahl) 0 > &&
'			{if}
'		1 (S.L.display1_retarder2)
'			{else}
'		0 (S.L.display1_retarder2)
'			{endif}
'
'	(L.L.elec_busbar_main) 0 >
'	(L.L.antrieb_wendesatz) 1 = &&
'	(L.L.brake) 0.25 >= &&
'	(L.L.display_idle_visible) 1 = &&
'	(L.L.antrieb_getr_gangwahl) 0 > &&
'			{if}
'		1 (S.L.display1_retarder3)
'			{else}
'		0 (S.L.display1_retarder3)
'			{endif}
				
	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = || (L.L.display_2_visible) 1 = || (L.L.display_3_visible) 1 = || (L.L.display_4_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.display_option) 1 = &&
	(L.L.startup_display) 8 > &&
		{if}
			1 (S.L.display_temp_visible)
		{else}
			0 (S.L.display_temp_visible)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.display_option) 2 = &&
	(L.L.elec_busbar_main) 0 > &&
	(L.L.startup_display) 8 > &&
		{if}
			1 (S.L.display_aussentemp_visible)
			1 (S.L.display1_aussentemp_symbol)
		{else}
			0 (S.L.display_aussentemp_visible)
			0 (S.L.display1_aussentemp_symbol)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.display_option) 3 = &&
	(L.L.elec_busbar_main) 0 > &&
	(L.L.startup_display) 8 > &&
		{if}
			1 (S.L.display_clock_visible)
			1 (S.L.display1_clock_symbol)
		{else}
			0 (S.L.display_clock_visible)
			0 (S.L.display1_clock_symbol)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.startup_display) 8 > &&
		{if}
			1 (S.L.display_enginetemp_visible)
		{else}
			0 (S.L.display_enginetemp_visible)
		{endif}

	(L.L.display_idle_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.cp_taster_heat_or_frost) 1 = &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 3.5 > (L.L.startup_display) 4 < && ||
		{if}
			1 (S.L.display1_AC)
		{else}
			0 (S.L.display1_AC)
		{endif}

	(L.L.display_idle_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.kneel_auto_set) 1 = &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 1.5 > (L.L.startup_display) 2 < && ||
		{if}
			1 (S.L.display1_Autokneel)
		{else}
			0 (S.L.display1_Autokneel)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.cp_klappfenster_OL3) &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 3 > (L.L.startup_display) 3.5 < && ||
		{if}
			1 (S.L.display1_Dachluke)
		{else}
			0 (S.L.display1_Dachluke)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.antrieb_getr_aktugang) 0 = &&
	(L.L.antrieb_getr_gangwahl) 1 = &&
	(L.L.startup_display) 8 > &&
		{if}
			1 (S.L.display1_gear_N)
		{else}
			0 (S.L.display1_gear_N)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.stoermeldung_aktiv) 0 > &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 5 > (L.L.startup_display) 5.5 < && ||
		{if}
			1 (S.L.display1_Diagnose)
		{else}
			0 (S.L.display1_Diagnose)
		{endif}

	(L.L.display_idle_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.cp_taster_standheizung_target) 1 = &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 2 > (L.L.startup_display) 2.5 < && ||
		{if}
			1 (S.L.display1_standheizung)
		{else}
			0 (S.L.display1_standheizung)
		{endif}

	(L.L.display_idle_visible) 1 =
	(L.L.elec_busbar_main) 0 > &&
	(L.L.cp_dummy_sw06) 1 = &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 2.5 > (L.L.startup_display) 3 < && ||
		{if}
			1 (S.L.display1_spiegelheizung)
		{else}
			0 (S.L.display1_spiegelheizung)
		{endif}

	(L.L.cp_ASR_off) 1 =
	(L.L.engine_ASR_eingriff) ||
	(L.L.display_idle_visible) 1 = &&
	(L.L.elec_busbar_main) 0 > &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 1 > (L.L.startup_display) 1.5 < && ||
		{if}
			1 (S.L.display1_ASR)
		{else}
			0 (S.L.display1_ASR)
		{endif}

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.door_kinderwagenwunsch) 1 = &&
	(L.L.startup_display) 8 > &&
	(L.L.startup_display) 4.5 > (L.L.startup_display) 5 < && ||
		{if}
			1 (S.L.display1_kinderwagenwunsch)
		{else}
			0 (S.L.display1_kinderwagenwunsch)
		{endif}

'Verbrauchsanzeige:

	(L.L.display_idle_visible) 1 = (L.L.display_1_visible) 1 = || (L.L.display_2_visible) 1 = || (L.L.display_3_visible) 1 = || (L.L.display_4_visible) 1 = ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.display_option) 2 = &&
	(L.L.display1_Dachluke) 0 = &&
		{if}
			1 (S.L.display_verbrauch)
			1 (S.L.display_verbrauch_h)
			1 (S.L.display_verbrauch_100km)
		{else}
			0 (S.L.display_verbrauch)
			0 (S.L.display_verbrauch_h)
			0 (S.L.display_verbrauch_100km)
		{endif}

'Stцrungsmelder:

'	Signalgeber:
	(L.L.engine_temperature) 106 >
	(L.L.EBS_Error_dist) 100 > ||
	(L.L.elec_busbar_main) 0 > &&
	{if}
		(L.L.stoermeldung_aktiv) 1 + (S.L.stoermeldung_aktiv)
		1 =
		{if}
			(T.L.ev_stoermeldung)
		{endif}
	{endif}

'	Druckwarnung:
	(L.L.bremse_p_tank01) 650000 <
	(L.L.bremse_p_tank02) 650000 < ||
	(L.L.bremse_p_tank03) 650000 < ||
	(L.L.elec_busbar_main) 0 > &&
	(L.L.engine_n) 300 > &&
	(L.L.startup_display) 8 > &&
	{if}
		1 (S.L.display_warn_druck)
	{else}
		0 (S.L.display_warn_druck)
	{endif}

'	Verbraucherwarnung:
	(L.L.lights_stand) 1 =
	(L.L.lights_sw_blinker) 0 > ||
	(L.L.lights_sw_warnblinker) ||
	(L.L.schulfahrschaltung) ||
	(L.L.cp_licht_unterdeck_sw) ||
	(L.L.cp_licht_oberdeck_sw) ||
	(L.L.cp_licht_untenrechts_sw) ||
	(L.L.elec_busbar_main) 0 = &&
	(L.L.engine_n) 300 < &&
	{if}
		1 (S.L.display_verbraucher)
	{else}
		0 (S.L.display_verbraucher)
	{endif}

'	EBS/ASR-Fehler:
	(L.L.EBS_Error_dist) (L.L.velocity) 3600 / (L.S.Timegap) * + (S.L.EBS_Error_dist)
	100 >
	(L.L.elec_busbar_main) 0 > &&
	(L.L.display_warn_pressure) 0 = &&
	(L.L.warning_quit) 0 = &&
	(L.L.startup_display) 8 > &&
	{if}
		1 (S.L.display_warn_EBSASR)
	{endif}

'	Temperaturwarnung:
	(L.L.engine_temperature) 106 >
	(L.L.elec_busbar_main) 0 > &&
	(L.L.warning_quit) 0 = &&
	(L.L.startup_display) 8 > &&
	{if}
		1 (S.L.display_warn_pressure)
	{endif}

'	Stцrmeldungslцschung:
	(L.L.engine_temperature) 106 <
	(L.L.EBS_Error_dist) 100 < &&
	(L.L.elec_busbar_main) 0 > &&
	{if}
		0 (S.L.stoermeldung_aktiv)
		0 (S.L.warning_quit)
	{endif}

'	Manuelle Stцrmeldungsquittierung:
	(L.L.comp_button_qiut_mode) 1 =
	{if}
		0 (S.L.display_warn_pressure) (S.L.display_warn_EBSASR)
	{endif}

'	Quittierung der Warnungen, wenn Strom abfдllt.
	(L.L.elec_busbar_main) 0 =
	{if}
		0 (S.L.display_warn_pressure)
		0 (S.L.display_warn_EBSASR)
		1 (S.L.warning_quit)
		1 (S.L.number_of_display)
	{endif}

'	(L.L.comp_button_system_mode) 1 =
'	(L.L.stoermeldung_aktiv) 0 > &&
'	{if}
'		1 (S.L.display_warn_pressure)
'	{endif}
'А это выключение всех экранов когда выключается основное электричество:

	(L.L.elec_busbar_main) !
		{if}
			0 (S.L.display_idle_visible) (S.L.display_1_visible) (S.L.display_2_visible) (S.L.display_3_visible) (S.L.display_4_visible) (S.L.display_5_visible)
		{endif}

' Display-Delay

	(L.L.number_of_display) 1 =
		{if}
		(L.L.door_0) 0 =
		(L.L.door_1) 0 = &&
		(L.L.door_2) 0 = &&
		(L.L.door_3) 0 = &&
		(L.L.door_4) 0 = &&
		(L.L.door_5) 0 = &&
		(L.L.light_timer1) 1 >= &&
		(L.L.light_timer2) 1 >= &&
		(L.L.light_timer3) 1 >= &&
		(L.L.bremse_halte) 0 = &&
		(L.L.cockpit_light_feststellbremse) 0 = &&
		(L.L.automatic_N_light) 0 = &&
			{if}
			(L.L.turnover_timer) (L.S.timegap) + 0.5 min (S.L.turnover_timer)
			(L.L.turnover_timer) 0 > (L.L.turnover_timer) 0.5 < &&
			(L.L.display_warn_druck) 0 = &&
			(L.L.display_warn_pressure) 0 = &&
			(L.L.display_warn_EBSASR) 0 = &&
				{if}
				1 (S.L.display_empty_visible)
				{else}
				0 (S.L.display_empty_visible)
				{endif}
			{else}
			(L.L.turnover_timer) (L.S.timegap) - 0 max (S.L.turnover_timer)
			(L.L.turnover_timer) 0 > (L.L.turnover_timer) 0.5 < &&
			(L.L.display_warn_druck) 0 = &&
			(L.L.display_warn_pressure) 0 = &&
			(L.L.display_warn_EBSASR) 0 = &&
				{if}
				1 (S.L.display_empty_visible)
				{else}
				0 (S.L.display_empty_visible)
				{endif}
			{endif}
		{endif}

'##############################################################
'#######Появление индикаторов при определенных условиях########
'##############################################################

'Можно было вписать сюда туеву хучу условий экранов, но всё должно быть культурно, поэтому я разбил их по 4 разным файлам, чтобы было разобраться в чем пока потягиваешь пиво




'Скрипт суточного одометра и полного от Дмитрия, извини что не оповестил, но скрипт твой очень подошел. Надеюсь, ты не будешь против =)
	(L.L.kmcounter_km) (L.L.kmcounter_m) 1000 / + (S.L.km_counter_km)
	(L.L.km_counter_km) 10 * trunc 10 / (S.L.km_counter_km)
	(L.L.kmcounter_m) "04" $IntToStrEnh 3 $SetLengthR (S.$.km_counter_m)
	(L.$.km_counter_m) 1 $SetLengthL $StrToFloat trunc (S.L.km_counter_m)
'	-------------------------


	(L.L.km_counter_km) (L.L.km_counter_km_last) - (S.L.km_counter_km_day)
	(L.L.km_counter_m) (L.L.km_counter_m_last) <
	{if}
		10 (L.L.km_counter_m) + (L.L.km_counter_m_last) - (S.L.km_counter_m_day)
	{else}
		(L.L.km_counter_m) (L.L.km_counter_m_last) - (S.L.km_counter_m_day)
	{endif}
	
	(L.L.elec_busbar_main)
	{if}
'		Расчет общего пробега
		(L.L.km_counter_km) trunc " 7" $IntToStrEnh 5 $SetLengthR
		"." $+
		(L.$.km_counter_m) 1 $SetLengthL $+
		(S.$.odometr_full)

'		Расчет суточного пробега
		(L.L.km_counter_km_day) " 4" $IntToStrEnh
		"." $+
		(L.L.km_counter_m_day) trunc $IntToStr $+
		" " $+
		(S.$.odometr_day)
		
'		Если суточный пробег будет больше 9999 км, то он автоматически сбросится (защита от дурака)		
		(L.L.km_counter_km_day) 9999 >=
		{if}
			0 (S.L.odometr_sbros)
		{endif}
		
		(L.L.odometr_sbros) 0 =
		{if}
			(L.L.km_counter_km) (S.L.km_counter_km_last)
			(L.L.km_counter_m) (S.L.km_counter_m_last)
			1 (S.L.odometr_sbros)
		{endif}
		
	{else}
		" " $ (S.$.odometr_full)
		" " $ (S.$.odometr_day)
	{endif}

'Тест
(L.L.engine_tank_content) $IntToStr (S.$.engine_tank_content1)

' Цифровые часы Автор Славок
 (L.S.Time) 3600 / trunc " 2" s0
 (L.S.Time) 60 / l0 60 * - s1 
 
 l0 10 <
 {if}
  "0" l0 $IntToStr $+
 {else}
  l0 $IntToStr
 {endif}
 
 l1 10 <
 {if}
  ":0" $+ l1 $IntToStr $+
 {else}
  ":" $+ l1 $IntToStr $+
 {endif}
 
 (S.$.vdo_panel_time)

	(L.L.Velocity) $IntToStr (S.$.vdo_panel_speed)
{end}

{macro:kippschaltersound_toggle}
	l0
	{if}
		(T.L.ev_VDV_toggle_on)
	{else}
		(T.L.ev_VDV_toggle_off)
	{endif}	
{end}